﻿<src:OverlayWindow x:Class="GW2PAO.Views.OverlayMenuIconView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:src="clr-namespace:GW2PAO.Views"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:core="clr-namespace:GW2PAO.PresentationCore;assembly=GW2PAO.PresentationCore"
        Title="OverlayMenuIconView" SizeToContent="WidthAndHeight"
        WindowStyle="None" AllowsTransparency="true" Background="Transparent"
        ResizeMode="NoResize"
        Topmost="True"
        Closing="OverlayMenuIconView_Closing">
    <src:OverlayWindow.Resources>

        <Style TargetType="ToolTip" x:Key="OverlayIconToolTipStyle">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="HasDropShadow" Value="True"/>
            <Setter Property="TextBlock.Foreground" Value="White"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ToolTip">
                        <Border Name="Border" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
                                BorderThickness="2" CornerRadius="3">
                            <Border.Background>
                                <LinearGradientBrush>
                                    <GradientStop Color="#FF24313D" Offset="0"/>
                                    <GradientStop Color="#8024313D" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Border.BorderBrush>
                                <SolidColorBrush Color="Black" Opacity="1" />
                            </Border.BorderBrush>
                            <ContentPresenter Margin="4,5,4,5" HorizontalAlignment="Left" VerticalAlignment="Top" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="HasDropShadow" Value="true">
                                <Setter TargetName="Border" Property="CornerRadius" Value="2"/>
                                <Setter TargetName="Border" Property="SnapsToDevicePixels" Value="true"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>

            <Style.Triggers>
                <Trigger Property="Content" Value="{x:Static sys:String.Empty}">
                    <Setter Property="Visibility" Value="Collapsed" />
                </Trigger>
                <Trigger Property="Content" Value="{x:Null}">
                    <Setter Property="Visibility" Value="Collapsed" />
                </Trigger>
            </Style.Triggers>
        </Style>

    </src:OverlayWindow.Resources>

    <Grid Name="MainGrid" HorizontalAlignment="Center" VerticalAlignment="Center">

        <Popup Name="NowRunningPopup"
               HorizontalAlignment="Left" VerticalAlignment="Top"
               PlacementTarget="{Binding ElementName=IconImage}"
               AllowsTransparency="True" PopupAnimation="Fade"
               HorizontalOffset="24">
            <Grid>
                <Path Stretch="Fill" Stroke="Black" StrokeThickness="2" StrokeLineJoin="Round"
                      Margin="0" Data="M0,0 L50,30 275,30 275,100 25,100 25,50 z">
                    <!--Data="M130,154 L427.5,154  427.5,240.5  299.5,240.5  287.5,245.5  275.5,240.5  130,240.5 z">-->
                    <Path.Effect>
                        <DropShadowEffect BlurRadius="12" Color="Black" Direction="315" Opacity="0.8"/>
                    </Path.Effect>

                    <Path.Fill>
                        <LinearGradientBrush>
                            <GradientStop Color="#FF24313D" Offset="0"/>
                            <GradientStop Color="#8024313D" Offset="1"/>
                        </LinearGradientBrush>
                    </Path.Fill>
                </Path>

                <Grid>
                    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"
                                Margin="30,30,0,0">
                    
                        <core:OutlinedTextBlock Fill="White" FontWeight="Bold" FontSize="15"
                                                Text="GW2 Personal Assistant Overlay" />
                        <core:OutlinedTextBlock Fill="White" FontSize="12"
                                                Text="is now running" />
                        <core:OutlinedTextBlock Margin="0,10,0,0"
                                                Fill="White" FontSize="12" FontWeight="Bold"
                                                Text="Click Here to Get Started" />
                    </StackPanel>
                </Grid>
            </Grid>
        </Popup>

        <Image Name="IconImage"
               Source="../Resources/OverlayMenuIcon.png"
               Margin="4,4,4,4"
               Height="24" Width="24"
               ToolTipService.InitialShowDelay="0"
               MouseDown="Image_MouseDown"
               MouseEnter="Image_MouseEnter">
            <Image.ToolTip>
                <ToolTip Style="{StaticResource OverlayIconToolTipStyle}">
                    <TextBlock FontFamily="Gisha" Text="GW2 Personal Assistant Overlay" />
                </ToolTip>
            </Image.ToolTip>
            <Image.ContextMenu>
                <ContextMenu Name="MainMenu">
                    <ContextMenu.ItemContainerStyle>
                        <Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
                            <Setter Property="Command" Value="{Binding OnClickCommand}" />
                            <Setter Property="IsCheckable" Value="{Binding IsCheckable}" />
                            <Setter Property="IsChecked" Value="{Binding IsChecked}" />
                            <Setter Property="Header" Value="{Binding Header}" />
                            <Setter Property="ItemsSource" Value="{Binding SubMenuItems}" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding}" Value="{x:Null}">
                                    <Setter Property="Template" Value="{StaticResource MenuSeparatorTemplate}" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ContextMenu.ItemContainerStyle>
                </ContextMenu>
            </Image.ContextMenu>
        </Image>
        <Grid.Style>
            <Style TargetType="{x:Type Grid}">
                <Setter Property="RenderTransformOrigin" Value="0.5, 0.5"/>
                <Setter Property="Opacity" Value="0.5" />
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation To="0.9" Storyboard.TargetProperty="Opacity" Duration="00:00:00.5"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                        <Trigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation To="0.5" Storyboard.TargetProperty="Opacity" Duration="00:00:00.5"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.ExitActions>
                        <Setter Property="RenderTransform">
                            <Setter.Value>
                                <ScaleTransform ScaleX="1.1" ScaleY="1.1" CenterX="1" CenterY="1"/>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Grid.Style>
    </Grid>
    
</src:OverlayWindow>
